﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraEditors;
using DevExpress.XtraBars.Docking;
using PTTB.PL;


namespace PTTB
{
    public partial class frmMain : XtraForm
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void iExit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Application.Exit();
        }

        private void navBarItem1_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            AddForm(new frmYeuCauKhaoSat());
        }

        private void AddForm(Form FrmCon)
        {
            Form[] childArr = this.MdiChildren;
            bool isExist = false;
            Form currentForm = null;
            foreach (Form f in childArr)
            {
                if (f.Name == FrmCon.Name)
                {
                    isExist = true;
                    currentForm = f;
                    break;
                }
            }
            if (isExist == true)
                currentForm.Select();
            else
            {
                FrmCon.MdiParent = this;
                FrmCon.Show();
            }
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            navBarControl.Enabled = false;
            iDangNhap_ItemClick(null, null);
        }

        private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            AddForm(new frmDatMoi());
        }

        private void iDangNhap_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            new frmLogin().ShowDialog();
            navBarControl.Enabled = true;
        }

        private void iDangXuat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Form[] childArr = this.MdiChildren;
            foreach (Form f in childArr)
            {
                f.Close();
            }
            navBarControl.Enabled = false;
        }


    }
}